package cn.hua.trip.base.domain;

import cn.hua.trip.base.util.JSONUtil;
import lombok.*;

import java.util.HashMap;

@Setter
@Getter
@AllArgsConstructor
@NoArgsConstructor
@ToString
public class StrategyCatalog extends BaseDomain {

    public static final boolean STATE_NOMAL = true;  //正常
    public static final boolean STATE_DISABLE = false; //禁用


    private String name;

    private Strategy strategy;

    private Integer sequence;

    private Boolean state =STATE_NOMAL;

    public String getStateDisplay() {
        String temp = "";
        if (state == STATE_NOMAL) {
            temp = "正常";
        } else if (state == STATE_DISABLE) {
            temp = "禁用";
        }
        return temp;
    }

    public String getJsonString(){
        HashMap<String, Object> map = new HashMap<>();
        map.put("id",getId());
        map.put("name",name);
        map.put("sequence",sequence);
        map.put("state",state);
        if (strategy!=null){
            map.put("strategyId",strategy.getId());
        }
        return JSONUtil.toJSONString(map);
    }

}